package com.lekang.le.service.impl;

import java.util.List;
import com.lekang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lekang.le.mapper.AppointmentRegistrationMapper;
import com.lekang.le.domain.AppointmentRegistration;
import com.lekang.le.service.IAppointmentRegistrationService;

/**
 * 预约登记Service业务层处理
 * 
 * @author caoyangyang
 * @date 2025-10-14
 */
@Service
public class AppointmentRegistrationServiceImpl implements IAppointmentRegistrationService 
{
    @Autowired
    private AppointmentRegistrationMapper appointmentRegistrationMapper;


    /**
     * 查询预约登记
     * 
     * @param id 预约登记主键
     * @return 预约登记
     */
    @Override
    public AppointmentRegistration selectAppointmentRegistrationById(Long id)
    {
        return appointmentRegistrationMapper.selectAppointmentRegistrationById(id);
    }

    /**
     * 查询预约登记列表
     * 
     * @param appointmentRegistration 预约登记
     * @return 预约登记
     */
    @Override
    public List<AppointmentRegistration> selectAppointmentRegistrationList(AppointmentRegistration appointmentRegistration)
    {
        return appointmentRegistrationMapper.selectAppointmentRegistrationList(appointmentRegistration);
    }

    /**
     * 新增预约登记
     * 
     * @param appointmentRegistration 预约登记
     * @return 结果
     */
    @Override
    public int insertAppointmentRegistration(AppointmentRegistration appointmentRegistration)
    {
        appointmentRegistration.setCreateTime(DateUtils.getNowDate());
        return appointmentRegistrationMapper.insertAppointmentRegistration(appointmentRegistration);
    }

    /**
     * 修改预约登记
     * 
     * @param appointmentRegistration 预约登记
     * @return 结果
     */
    @Override
    public int updateAppointmentRegistration(AppointmentRegistration appointmentRegistration)
    {
        return appointmentRegistrationMapper.updateAppointmentRegistration(appointmentRegistration);
    }

    /**
     * 批量删除预约登记
     * 
     * @param ids 需要删除的预约登记主键
     * @return 结果
     */
    @Override
    public int deleteAppointmentRegistrationByIds(Long[] ids)
    {
        return appointmentRegistrationMapper.deleteAppointmentRegistrationByIds(ids);
    }

    /**
     * 删除预约登记信息
     * 
     * @param id 预约登记主键
     * @return 结果
     */
    @Override
    public int deleteAppointmentRegistrationById(Long id)
    {
        return appointmentRegistrationMapper.deleteAppointmentRegistrationById(id);
    }

    @Override
    public int updateAppointmentRegistrationArrivaltimeById(AppointmentRegistration appointmentRegistration) {
        return appointmentRegistrationMapper.updateAppointmentRegistrationArrivaltimeById(appointmentRegistration);
    }

    /**
     * 查询用户今天的预约次数（探访+参观）
     * 
     * @param wxUserId 微信用户ID
     * @return 今天的预约次数
     */
    @Override
    public int getTodayAppointmentCount(Long wxUserId)
    {
        return appointmentRegistrationMapper.getTodayAppointmentCount(wxUserId);
    }

    /**
     * 查询用户今天的取消预约次数
     * 
     * @param wxUserId 微信用户ID
     * @return 今天的取消预约次数
     */
    @Override
    public int getTodayCancelCount(Long wxUserId)
    {
        return appointmentRegistrationMapper.getTodayCancelCount(wxUserId);
    }
}
